package com.martin.dms.model.hib;

import java.util.Date;

import com.martin.dms.model.Delivery;
import com.martin.dms.model.Item;
import com.martin.dms.model.Supplier;

/**
 * Hibernate delivery implementation.
 * 
 * @author mtsvetkov
 */
public class DeliveryHib implements Delivery {

    private Long id;

    private Supplier supplier;
    private Item item;
    private int amount;
    private Date date;

    /**
     * Default constructor.
     */
    public DeliveryHib() {
    }

    /**
     * {@inheritDoc}
     */
    public Long getId() {
        return id;
    }

    /**
     * {@inheritDoc}
     */
    public int getAmount() {
        return amount;
    }

    /**
     * Sets the amount of the delivered items.
     * 
     * @param amount - the amount of the delivered items.
     */
    public void setAmount(int amount) {
        this.amount = amount;
    }

    /**
     * {@inheritDoc}
     */
    public Date getDate() {
        return date;
    }

    /**
     * Sets the date of the delivery.
     * 
     * @param date - the date of the delivery.
     */
    public void setDate(Date date) {
        this.date = date;
    }

    /**
     * {@inheritDoc}
     */
    public Item getItem() {
        return item;
    }

    /**
     * Sets the item that was delivered.
     * 
     * @param item - the item that was delivered.
     */
    public void setItem(Item item) {
        this.item = item;
    }

    /**
     * {@inheritDoc}
     */
    public Supplier getSupplier() {
        return supplier;
    }

    /**
     * Sets the supplier that made the delivery.
     * 
     * @param supplier - the supplier that made the delivery.
     */
    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    /**
     * {@inheritDoc}
     */
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof DeliveryHib)) {
            return false;
        }
        final DeliveryHib delivery = (DeliveryHib) obj;
        if (delivery.getId() != null && this.getId() != null) {
            return delivery.getId().equals(this.getId());
        }
        return false;
    }

    /**
     * {@inheritDoc}
     */
    public int hashCode() {
        int result = 17;
        if (getId() != null) {
            result += 37 * result + getId().hashCode();
        }
        return result;
    }
}
